From: Giovanni Campagna Date: Sat, 15 Mar 2014 11:40:13 +0000 (+0100) Subject: NetworkMenu: make sure menu icons are updated at the end of connectivity checks X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~2381 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5f4591e24c033fde1cb9cd50c70f9843528a5329;p=gnome-shell.git NetworkMenu: make sure menu icons are updated at the end of connectivity checks Icons inside the menu are updated only for device state change, but for the main device they also depend on connectivity (which is a global property). Add a public method to force an update of the icon, and call it when connectivity changes. https://bugzilla.gnome.org/show_bug.cgi?id=726401 --- diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 7d68fbd53..f3e568dd6 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -207,13 +207,23 @@ const NMConnectionSection = new Lang.Class({ this.item.menu.addMenuItem(this._labelSection); this.item.menu.addMenuItem(this._radioSection); - this.connect('icon-changed', Lang.bind(this, this._sync)); + this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, this._iconChanged)); }, destroy: function() { + if (this._notifyConnectivityId != 0) { + this._client.disconnect(this._notifyConnectivityId); + this._notifyConnectivityId = 0; + } + this.item.destroy(); }, + _iconChanged: function() { + this._sync(); + this.emit('icon-changed'); + }, + _sync: function() { let nItems = this._connectionItems.size; @@ -278,7 +288,7 @@ const NMConnectionSection = new Lang.Class({ return; item.connect('icon-changed', Lang.bind(this, function() { - this.emit('icon-changed'); + this._iconChanged(); })); item.connect('activation-failed', Lang.bind(this, function(item, reason) { this.emit('activation-failed', reason); @@ -523,7 +533,7 @@ const NMDeviceModem = new Lang.Class({ if (this._mobileDevice) { this._operatorNameId = this._mobileDevice.connect('notify::operator-name', Lang.bind(this, this._sync)); this._signalQualityId = this._mobileDevice.connect('notify::signal-quality', Lang.bind(this, function() { - this.emit('icon-changed'); + this._iconChanged(); })); } }, @@ -1145,10 +1155,16 @@ const NMDeviceWireless = new Lang.Class({ this._wirelessHwEnabledChangedId = this._client.connect('notify::wireless-hardware-enabled', Lang.bind(this, this._sync)); this._activeApChangedId = this._device.connect('notify::active-access-point', Lang.bind(this, this._activeApChanged)); this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, this._deviceStateChanged)); + this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, this._iconChanged)); this._sync(); }, + _iconChanged: function() { + this._sync(); + this.emit('icon-changed'); + }, + destroy: function() { if (this._activeApChangedId) { GObject.Object.prototype.disconnect.call(this._device, this._activeApChangedId); @@ -1174,6 +1190,10 @@ const NMDeviceWireless = new Lang.Class({ this._dialog.destroy(); this._dialog = null; } + if (this._notifyConnectivityId) { + this._client.disconnect(this._notifyConnectivityId); + this._notifyConnectivityId = 0; + } this.item.destroy(); }, @@ -1211,7 +1231,7 @@ const NMDeviceWireless = new Lang.Class({ }, _strengthChanged: function() { - this.emit('icon-changed'); + this._iconChanged(); }, _activeApChanged: function() {